var combinations = (function() {
    var res = [];

    function combinations(arr, k, start, idx, current) {
        if (idx === k) {
            res.push(current.slice());
            return;
        }
        for (var i = start; i < arr.length; i += 1) {
            current[idx] = arr[i];
            combinations(arr, k, i + 1, idx + 1, current);
        }
    }
    return function(arr, k) {
        res = [];
        combinations(arr, k, 0, 0, []);
        var temp = res;
        // Free the extra memory
        res = null;
        return temp;
    };
}());

function solve(a, b) {
    b = b.replace(new RegExp(`[^${a}]`, 'g'), '');

    if (b.length > 60) return 'i can do it'
    //return (combinations([...b], a.length).filter(v => v.join('') === a) || []).length
}

solve("zaz", "zazapulz")
